﻿<!--
<!DOCTYPE html PUBLIC "-//W3C//DTD html 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<html><HEAD><TITLE>需求一览表</TITLE>
    <script th:src="@{/js/vue2.js}"></script>
    <script th:src="@{/js/axios.js}"></script>
    <script th:src="@{/css/bootstrap/js/bootstrap.js}"></script>
    <script th:src="@{/js/jquey.min.js}"></script>
    <link rel="stylesheet" th:href="@{/css/bootstrap/css/bootstrap.css}">
<SCRIPT language=JAVASCRIPT>
function select_check(theForm)
      {
        var count=0;
        for (var k = 0; k < theForm.length; k++)
        if ((theForm[k].type == "checkbox") && (theForm[k].checked))
        count++;
         if (count==0)
         {
            for (k = 0; k < theForm.length; k++)
            {
              if (theForm[k].type == "checkbox")
              theForm[k].checked=true;
            }
         }
         else
         {
            for (k = 0; k < theForm.length; k++)
            {
              if (theForm[k].type == "checkbox")
              theForm[k].checked=false;
            }
         }
      }
function chck()
{  var  count=0;
   for (var i=0;i<form.length;i++)
   if ((form[i].type == "radio") && (form[i].checked))
   count++; 
   if (count==0)
      { return false;  }
   else
      { return true;   }
}
 
function Add(SourceList,TargetList)
	{
	var nIndex = SourceList.selectedIndex;
 	var nCount = 0;  
	if (nIndex == -1)
	{
		// Process continue only if at least one item selected
		//alert("请先选择一项!");
		return;
	}
	for (i=0;i<SourceList.length;i++)
  {
     if (SourceList.options(i).selected==true)
     {    
         if (inSouceList(SourceList.options(i).value,TargetList)==false)
         {
          	var objSelected = new Option(SourceList[i].text, SourceList[i].value);
           	TargetList.options[TargetList.length] = objSelected;
         }
     }     
	}
  for (var i=0;i<TargetList.options.length;i++)
  {
    TargetList.options(i).selected=true;
  }
	if(navigator.appName=="Netscape")
	{
		history.go(0)
	}
 }
 function inSouceList(SourceListOption,TargetList)
 {
 	  for (i=0;i<TargetList.length;i++)
    {
	     if (TargetList.options[i].value==SourceListOption)
       {
        	 return true;
       }
    }   
    return false;
 }  
function Remove(SelectList)
	{
	var nIndex = SelectList.selectedIndex;
 	var nCount = 0;
	if (nIndex == -1)
	{
		// Process continue only if at least one item selected
		//alert("请先选择一项!");
		return;
	}
  while(nCount<SelectList.length)
  {
       if (SelectList.options(nCount).selected==true)
       {
       	 SelectList.options[nCount] = null;
       }
       else
       {
         nCount++;
       }
  }
	if(navigator.appName=="Netscape")
		{
		history.go(0)
		}	
	}
 function enter()
 {
   var srcEle = window.event.srcElement;
   var tmp;   
   tmp = window.showModalDialog("pub_pub.Dialog_Date?vc_input=" + srcEle.value);
     if ( tmp.indexOf("/") != -1)
     {
        srcEle.value = tmp;
     }
     return;
 }   
 function check_num()
 {
 	 if (window.event.keyCode > 57 || window.event.keyCode < 48)
	 {
	 		window.event.returnValue = false;
	 }
 }
 function check_blank()
 {
 	 if (window.event.keyCode < 48)
	 {
	 		window.event.returnValue = false;
	 }
 }
  
function check_num_dot()
{
 	 if (window.event.keyCode > 57 || window.event.keyCode < 46)
	 {
  		 window.event.returnValue = false;   
	 }
   else
   {
      if(window.event.keyCode==47)
      {
    		 window.event.returnValue = false;
      }
      if(window.event.keyCode==46)
      {
         if (window.event.srcElement.value.indexOf(".")!=-1)
         {
        		 window.event.returnValue = false;
         }
      }   
    }  
 }
  
 function submitonce(theform)
 {
 if (document.all || document.getElementById)
 {
 for (i=0;i<theform.length;i++)
 {
 var tempobj = theform.elements[i]
 if (tempobj.type.toLowerCase() =="button")
 tempobj.disabled = true
 }
 }
 }
 
  function CheckAll() 
 {
   var i = 0;
   for (i=0; i < window.document.forms[0].elements.length; i++) 
   {
     if(window.document.forms[0].elements[i].Chk<3) 
     {
       if(window.document.forms[0].elements[i].value=="")
       {
         alert(window.document.forms[0].elements[i].alt);
         window.document.forms[0].elements[i].focus();
         return;
       }
       else if (window.document.forms[0].elements[i].Chk==2)
       {
         if (NotNumber(window.document.forms[0].elements[i].value))
         {
            alert("提示信息：\n不是有效的数字，请重新输入。");
            window.document.forms[0].elements[i].focus();
            return;
         }
       }
     }
     else if(window.document.forms[0].elements[i].Chk==3)
     {
       if(window.document.forms[0].elements[i].value!="")
       {
         if (NotNumber(window.document.forms[0].elements[i].value))
         {
            alert("提示信息：\n不是有效的数字，请重新输入。");
            window.document.forms[0].elements[i].focus();
            return;
         }
       }
     }
   }
   window.document.forms[0].submit();
   return true;
 }
 function NotNumber(Field)
 {
   var j = 0;
   var k = 0;
   for (var i=0; i<Field.length; i++)
   {
      var ch=Field.substring(i,i+1);
      if((ch>="0")&&(ch<="9")) 
      {
        j=0;
      }
      else if(ch==".") 
      {
        k++;
      }
      else
      {
        j=1;
        break;
      }
   }
   if ((j==0)&&(k<2))
   {
      return false;
   }
   else
   {
      return true;
   }
 }
 function openwindown(page)
 {
    window.open(page,"newuser","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=400,left=100,top=150");
 }
 
 function print_order_detail(){
	  	window.open("print_order_detail.html","Canny2","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,width=600,height=440,left=100,top=60");
	  }
	  
	 
</SCRIPT>

<META http-equiv=Content-Language content=zh-cn>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content="MShtml 6.00.2900.5626" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId><LINK 
href="css/style.css" rel=stylesheet>
<SCRIPT language=JavaScript src="css/pub_Calendar.js"></SCRIPT>

<SCRIPT language=javascript>
      function submit_form(theForm,i)
      {
	  
        var count=0;
        for (var k = 0; k < theForm.length; k++)
        if ((theForm[k].type == "radio") && (theForm[k].checked))
        count++;
        if (count==0)
        {
          alert("提示信息：\n请选择需求计划。");
          return;
        }
        document.form.p_type.value=i;
        window.document.form.submit();
        return true;
      }
      function submit_form_cx()
      {
        form.action="Order_ytb_list.asp";
        window.document.form.submit();
      }
	   function workLog01() 
 	 {
  		window.open("work_log01.html","Canny1","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,width=600,height=440,left=100,top=60");
      
 	 }
	 
		 
	 function update_xuqiujihua(){
	
	 	var obj = document.getElementsByName("checkbox");
		var len = obj.length;
		var count=0;
		var no=0;
		for(var i=0;i<len;i++){
			if(obj[i].checked){
				count++;
				var objTable = document.getElementById("table1");
				var oldTr=objTable.rows[i+1];
				if(oldTr.cells[6].innerText=="确定"){
					alert("已确定的需求计划不能修改！");
					no=1;
					break;
				}
			}
		}
		if(count==0){
			alert("至少选择一条数据修改！");
		}else if(count>1){
			alert("一次只能修改一条数据！");
		}else if(no=0){
				window.location="update_xuqiujihua.html";
				}
	 }
	 
	  function quedingData(){
	 	var obj = document.getElementsByName("checkbox");
		var len = obj.length;
	 	var count=0;
		var no=0;
		for(var i=0;i<len;i++){
			if(obj[i].checked){
				count++;
				var objTable = document.getElementById("table1");
				var oldTr=objTable.rows[i+1];
				if(oldTr.cells[6].innerText=="确定"){
					alert("选定的数据中有数已确定，请重新选择。");
					no=1;
					break;
				}
			}
		}
		if(count==0){
			alert("至少选择一条数据！");
		}else if(no!=1){
			
			for(var i=0;i<len;i++){
			if(obj[i].checked){
				var objTable = document.getElementById("table1");
				var oldTr=objTable.rows[i+1];
				oldTr.cells[6].innerText="确定";
			}
		}
		}		
	}
	 
	 function getLen(){
		 obj01=document.getElementById("table1");
	 	cGetRow=window.event.srcElement.parentElement.parentElement.rowIndex;
	 }
	 
	 
	 function delData(){
	 	var obj = document.getElementById("p_orderno");
	 	if(obj.checked){
			obj01.deleteRow(cGetRow);
		}else{
			alert("请选择要删除的数据！");
		}
	 }
	
	 function opp(obj){
	  var c=document.getElementById("xiugai");
	   var d=document.getElementById("shanchu");
	  c.disabled=obj;
	   d.disabled=obj;
	 
	 }
	 
	  function ddtzDdmx() 
 	 {
	 	var obj = document.getElementsByName("checkbox");
		var len = obj.length;
	 	var count=0;
		for(var i=0;i<len;i++){
			if(obj[i].checked){
				count++;
			}
		}
		if(count==0){
			alert("至少选择一条数据！");
		}else if(count>1){
			alert("一次只能查看一条数据！");
		}else{
			window.open("print_order_detail.html","Canny2","toolbar=0,location=0,status=0,menubar=0,scrollbars=0,width=600,height=440,left=100,top=60");
			
		}
  		
      
 	 }
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<FORM name=form action=Order_ytb_do.asp method=post><INPUT type=hidden value=3 
name=p_type> 
<H2><FONT color=#0070c0>需求计划一览表</FONT></H2>
<TABLE cellSpacing=1 cellPadding=0 width="100%" bgColor=#ffffff 
borderColorLight=#ffffff border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
        <TBODY>
        <TR>
          <TD noWrap align=middle>物资编码：<INPUT size=10 
            name=p_prodno>&nbsp;&nbsp; 物资名称：<INPUT size=10 
            name=p_prodname>&nbsp;&nbsp; 状态：
            <SELECT style="WIDTH: 115px" 
            name=p_status>
              <OPTION value="" selected>全部</OPTION>
              <OPTION 
              value=70>未确定</OPTION>
              <OPTION 
              value=70>确定</OPTION>
            </SELECT> <INPUT onclick=submit_form_cx() type=button value=查询></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><FORM 
name="form1" action="" method="Post">
<CENTER><FONT color=#000064>◆&nbsp;</FONT><FONT color=#000064>首页 
上一页</FONT>&nbsp;<A 
href="http://169.254.158.100/zzdl/Order/Order_ytb_list.asp?p_type=3&amp;p_prodno=&amp;p_prodname=&amp;p_status=&amp;p_stocktype=&amp;p_ordertype=&amp;page=2"><FONT 
color=#0000be>下一页</FONT></A>&nbsp;<A 
href="http://169.254.158.100/zzdl/Order/Order_ytb_list.asp?p_type=3&amp;p_prodno=&amp;p_prodname=&amp;p_status=&amp;p_stocktype=&amp;p_ordertype=&amp;page=22"><FONT 
color=#0000be>尾页</FONT></A><FONT color=#000064>&nbsp;共 214 个需求计划 每页10 
个需求计划</FONT><FONT color=#000064>&nbsp;页次:<FONT 
color=blue>1</FONT>/22页</FONT><FONT color=#000064>&nbsp;◆&nbsp;</FONT> 
<TABLE style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%" 
bgColor=#336699 borderColorLight=#006699 border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 id="table1">
        <TBODY>
        <TR class=t1>
          <TD noWrap align=middle>选择</TD>
          <TD noWrap align=middle>序号</TD>
          <TD noWrap align=middle>物资代码</TD>
          <TD noWrap align=middle>物资名称</TD>
          <TD noWrap align=middle>数量</TD>
          <TD noWrap align=middle>需求状态</TD>
          </TR>
        <TR class=t2>
          <TD align=middle><label>
            <input type="checkbox" name="checkbox" value="checkbox" onClick="opp(true)">
            </label></TD>
          <TD>1</TD>
          <TD>W64001005001<BR></TD>
          <TD>晶振(HC-49U-500M-0.005%)<BR></TD>
          <TD align=right>222<BR></TD>
          <TD>制造中心采购</TD>
          <TD>未确认<BR></TD>
          </TR>
        <TR class=t2>
          <TD align=middle><label>
            <input type="checkbox" name="checkbox" value="checkbox" onClick="opp(false)">
          </label></TD>
          <TD>2</TD>
          <TD>W65000400101<BR></TD>
          <TD>CMOS电路(CD4001BCN)<BR></TD>
          <TD align=right>12<BR></TD>

          <TD>确定<BR></TD>
          </TR>
        <TR class=t2>
          <TD align=middle><input type="checkbox" name="checkbox" value="checkbox" onClick="opp(true)"></TD>
          <TD>3</TD>
          <TD>W64001005000<BR></TD>
          <TD>晶振(HC-49U-500K-0.005%)<BR></TD>
          <TD align=right>222<BR></TD>

          <TD>未确认<BR></TD>
          </TR>
        <TR class=t2>
          <TD align=middle><input type="checkbox" name="checkbox" value="checkbox" onClick="opp(true)"></TD>
          <TD>4</TD>
          <TD>WW0000000005<BR></TD>
          <TD>网络配件<BR></TD>
          <TD align=right>44444444444<BR></TD>

          <TD>未确认<BR></TD>
          </TR>
        </TBODY></TABLE></TD></TR></TBODY></TABLE><INPUT 
type=hidden value=3 name=p_listtype> <INPUT type=hidden value=1 name=page> 
<P align=center>
<INPUT name="button" type=button onclick=select_check(document.form) value=全选/取消>
<INPUT onClick="quedingData()" type=button value=确定>
<INPUT onClick="javascript:ddtzDdmx()" type=button value=详情> <INPUT onClick="update_xuqiujihua();" type=button value=修改 name=‘xiugai’> <INPUT onClick="delData();" type=button value=删除 name='shanchu'>
</P>
            </FORM></CENTER></CENTER></BODY></html>

--><!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="UTF-8">
  <title>需求计划一览表</title>
  <link href="css/style.css" rel="stylesheet">
  <script src="/js/vue2.js"></script>
  <script src="/js/axios.js"></script>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f8f8f8;
      color: #333;
      margin: 0;
      padding: 0;
    }
    .container {
      width: 90%;
      margin: 20px auto;
      background-color: #fff;
      padding: 20px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      border-radius: 5px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 20px;
    }
    th, td {
      padding: 12px;
      text-align: center;
      border: 1px solid #ddd;
    }
    th {
      background-color: #f2f2f2;
      color: #333;
    }
    .button-container {
      margin-top: 20px;
      text-align: center;
    }
    .action-button {
      padding: 10px 20px;
      margin: 5px;
      background-color: #336699;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s;
    }
    .action-button:hover {
      background-color: #28527a;
    }
    .pagination {
      margin-top: 20px;
      text-align: center;
    }
    .pagination button {
      padding: 8px 16px;
      margin: 0 2px;
      background-color: #0070c0;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s;
    }
    .pagination button:hover {
      background-color: #005f8a;
    }
    .pagination button:disabled {
      background-color: #ccc;
      cursor: not-allowed;
    }
    .status-unconfirmed {
      color: red;
    }
    .status-confirmed {
      color: green;
    }
    .status-unknown {
      color: gray;
    }
  </style>
</head>
<body>
<div id="app">
  <div class="container">
    <form @submit.prevent="fetchOrders">
      <h2><font color="#0070c0">需求计划一览表</font></h2>
      <table>
        <tr>
          <td>
            物资编码：<input v-model="materialCode" size="10" name="p_prodno">
            物资名称：<input v-model="materialName" size="10" name="p_prodname">
            状态：
            <select v-model="status" name="p_status">
              <option value="" selected>全部</option>
              <option value="未确定">未确定</option>
              <option value="确定">确定</option>
            </select>
            <input type="submit" value="查询">
          </td>
        </tr>
      </table>
    </form>
    <div class="pagination">
      <button @click="firstPage" :disabled="currentPage === 1">首页</button>
      <button @click="prevPage" :disabled="currentPage === 1">上一页</button>
      <button @click="nextPage" :disabled="currentPage === totalPages">下一页</button>
      <button @click="lastPage" :disabled="currentPage === totalPages">尾页</button>
      <span>共 {{ totalItems }} 个需求计划 每页 {{ pageSize }} 个需求计划</span>
      <span>页次: {{ currentPage }}/{{ totalPages }}页</span>
    </div>
    <table>
      <tr>
        <th>选择</th>
        <th>序号</th>
        <th>物资代码</th>
        <th>物资名称</th>
        <th>数量</th>
        <th>需求状态</th>
      </tr>
      <tr v-for="(order, index) in orders" :key="order.orderId">
        <td><input type="checkbox" v-model="selectedOrders" :value="order.orderId"></td>
        <td>{{ index + 1 + (currentPage - 1) * pageSize }}</td>
        <td>{{ order.materialCode }}</td>
        <td>{{ order.materialName }}</td>
        <td>{{ order.amount }}</td>
        <td :class="order.statusClass">{{ order.statusText }}</td>
      </tr>
    </table>
    <div class="button-container">
      <button class="action-button" @click="selectAll">全选/取消</button>
      <button class="action-button" @click="confirmOrders">确定</button>

    </div>
  </div>
</div>

<script>
  new Vue({
    el: '#app',
    data: {
      materialCode: '',
      materialName: '',
      status: '',
      orders: [],
      selectedOrders: [],
      totalItems: 0,
      currentPage: 1,
      pageSize: 5
    },
    computed: {
      totalPages() {
        return Math.ceil(this.totalItems / this.pageSize);
      }
    },
    methods: {
      fetchOrders() {
        axios.get('/findOrders', {
          params: {
            materialCode: this.materialCode,
            materialName: this.materialName,
            status: this.status,
            pageNum: this.currentPage,
            pageSize: this.pageSize
          }
        })
                .then(response => {
                  this.orders = response.data.data;
                  this.totalItems = response.data.total;
                  this.orders.forEach(order => {
                    if (order.status === 'C001-10') {
                      order.statusText = '未确认';
                      order.statusClass = 'status-unconfirmed';
                    } else if (order.status === 'C001-20') {
                      order.statusText = '已确认';
                      order.statusClass = 'status-confirmed';
                    } else {
                      order.statusText = '未知';
                      order.statusClass = 'status-unknown';
                    }
                  });
                })
                .catch(error => {
                  console.error('Error fetching orders:', error);
                });
      },
      firstPage() {
        if (this.currentPage !== 1) {
          this.currentPage = 1;
          this.fetchOrders();
        }
      },
      prevPage() {
        if (this.currentPage > 1) {
          this.currentPage--;
          this.fetchOrders();
        }
      },
      nextPage() {
        if (this.currentPage < this.totalPages) {
          this.currentPage++;
          this.fetchOrders();
        }
      },
      lastPage() {
        if (this.currentPage !== this.totalPages) {
          this.currentPage = this.totalPages;
          this.fetchOrders();
        }
      },
      selectAll() {
        if (this.selectedOrders.length === this.orders.length) {
          this.selectedOrders = [];
        } else {
          this.selectedOrders = this.orders.map(order => order.orderId);
        }
      },
      confirmOrders() {
        if (this.selectedOrders.length === 0) {
          alert("请选择至少一个订单！");
          return;
        }
        const orderIdsString = this.selectedOrders.join(',');
        axios.post('/updateOrderStatus', null, {
          params: {
            orderIds: orderIdsString
          }
        })
                .then(response => {
                  alert("状态更新成功！");
                  this.fetchOrders();
                  this.selectedOrders = [];
                })
                .catch(error => {
                  console.error('Error updating orders:', error);
                });
      },
      updateOrderPlan() {
        // 修改订单计划的逻辑
      },
      deleteOrders() {
        if (this.selectedOrders.length === 0) {
          alert("请选择至少一个订单！");
          return;
        }
        axios.post('/deleteOrders', {
          orderIds: this.selectedOrders
        })
                .then(response => {
                  this.fetchOrders();
                  this.selectedOrders = [];
                })
                .catch(error => {
                  console.error('Error deleting orders:', error);
                });
      }
    },
    mounted() {
      this.fetchOrders();
    }
  });
</script>
</body>
</html>




